<!DOCTYPE html>
<html>

<head>
    <title>系统消息</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/myProfiles.css"/>
    <link rel="stylesheet" href="/css/message.css"/>
    <script src="/js/plugins/jrender/jrender.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog/dialog.css"/>
    <script src="/js/plugins/dialog/dialog.min.js"></script>
    <script src="/js/common.js"></script>
</head>

<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="javascript:history.go(-1);">
                <span><i class="fa fa-chevron-left"></i></span>
            </a>
        </div>
        <div class="col">
            <span>系统消息</span>
        </div>
        <div class="col"></div>
    </div>
    <p>
</div>

<div class="container systemMsg">
    <dl class="itemList" render-loop="list">
        <dd>
            <p id="font" style="font-size:14;color:#367097">系统消息<img src='/img/Snip.png'></p>
            <p render-html="list.msg">-- 阿尔伯特·爱因斯坦</p>
            <p style="font-size:12;color:#367097" render-html="list.createTime">32分钟前</p>
        </dd>
    </dl>
</div>

</body>

<script>
    $(function () {
        //获取当前用户信息ID
        var id = getUser().id;
        var msgs;
        var currentPage = 1;
        var pages;
        //查询当前用户的所有系统消息
        $.get("/msgs/list", {userId: id}, function (data) {
            msgs = data.list;
            pages = data.pages;
            renderVal(data);
        })

        $(window).scroll(function () {
            if (isFull()) {
                if (currentPage < pages) {
                    $.get("/msgs/list", {currentPage: ++currentPage, userId: id}, function (data) {
                        $.merge(msgs, data.list);
                        renderVal({list: msgs});
                    })
                } else {
                    $(document).dialog({
                        type: "notice",
                        infoText: "到底部了",
                        autoClose: 2500,
                        position: "bottom"  // center: 居中; bottom: 底部
                    });
                }
            }

        })

        function renderVal(data) {
            $(".systemMsg").renderValues(data);
        }
        $.ajax({
            type: "POST",
            url:"/msgs/"+id,
            data:{"_method":"put"}
        })


    })


</script>


</html>